﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace BCS.WinFormAppGui
{
        public partial class PDFForm : Form
        {
                public String PdfFile { get; set; }

                public PDFForm()
                {
                        InitializeComponent();
                }

                private void Form_Load(object sender, EventArgs e)
                {
                        if (File.Exists(PdfFile))
                        {
                                axAcroPDF1.src = PdfFile;
                        }
                }

                private void ExportButton_Click(object sender, EventArgs e)
                {
                        DriveInfo[] dis = DriveInfo.GetDrives();
                        List<DriveInfo> ReadyDriveInfos = new List<DriveInfo>();

                        foreach (var di in dis)
                        {
                                if (di.DriveType == DriveType.Removable && di.IsReady)
                                {
                                        ReadyDriveInfos.Add(di);
                                }
                        }

                        if (ReadyDriveInfos.Count < 1)
                        {
                                MessageBox.Show("未找到可用的可移动磁盘");
                                return;
                        }

                        if (ReadyDriveInfos.Count > 1)
                        {
                                MessageBox.Show("可用的可移动磁盘过多，请移除无用的可移动磁盘");
                                return;
                        }

                        string diskDir = ReadyDriveInfos[0].RootDirectory.FullName;
                        string destFile = diskDir + @"\" + System.IO.Path.GetFileName(PdfFile);

                        File.Copy(PdfFile, destFile, true);

                        MessageBox.Show("导出完毕");
                }
        }
}
